#include "GameState.h"
#include "MainMenu.h"
#include "GameScreen.h"
#include "Globals.hpp"

int GameState::nextState = 0;
int GameState::stateID = 0;


void set_next_state( int newState )
{
    //If the user doesn't want to exit
    if( currentState->nextState != STATE_EXIT )
    {
        //Set the next state
        currentState->nextState = newState;
    }
}

void change_state()
{
    //If the state needs to be changed
    if( currentState->nextState != STATE_NULL )
    {
		// If the state is deleted...
		//int tempNextState = currentState->nextState;
        //Delete the current state
        //if( currentState->nextState != STATE_EXIT )
        //{
            //NullDelete(currentState);
        //}
        
        //Change the state
        switch( currentState->nextState )
        {     
            case STATE_MAINMENU:
				NullDelete(currentState);
                currentState = new MainMenu();
                break;

			case STATE_GAMEPLAY:
				NullDelete(currentState);
				currentState = new GameScreen();
				break;


        }
        
        //Change the current state ID
        currentState->stateID = currentState->nextState;
        
        //NULL the next state ID
        currentState->nextState = STATE_NULL;    
    }
}
